package mornd.test6;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootVersion;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.support.ResourcePropertySource;

import java.util.HashMap;

/**
 * @author: mornd
 * @dateTime: 2023/5/10 - 21:35
 * 打印 banner
 */
public class App {
    public static void main(String[] args) {
        StandardEnvironment environment = new StandardEnvironment();
        SpringApplicationBannerPrinter bannerPrinter =
                new SpringApplicationBannerPrinter(new DefaultResourceLoader(), new SpringBootBanner());


        environment.getPropertySources()
                .addLast(new MapPropertySource("custom", new HashMap<String, Object>() {{
                    put("spring.banner.image.location", "banner2.png");
                }}));

        System.out.println(App.class.getPackage().getImplementationVersion());

        System.out.println(SpringBootVersion.getVersion());

        bannerPrinter.print(environment, App.class, System.out);
    }
}
